package snake;

import gui::GUI;
import std::collection::ArrayList;

public class Snake : GameObject
{
	public Snake()
	{
		super();
		i->int = 0;
		while(i < s.length)
		{
			s[i][0] = i;
			s[i][1] = 0;
			++i;
		}
	}
	
	public update()
	{
		i->int = 0;
		while(i<s.length)
		{
			gui.draw(s[i][0], s[i][1], '*');
			++i;
		}
	}
	
	public update(x->int, y->int)->boolean
	{
		i->int=0;
		while(i+2<s.length)
		{
			if(x == s[i][0] && y == s[i][1])
			{
				return false;
			}
			++i;
		}
		if(x == s[s.length-2][0] && y == s[s.length-2][1])
		{
			return true;
		}
		i=0;
		while(i+1<s.length)
		{
			s[i][0] = s[i+1][0];
			s[i][1] = s[i+1][1];
			++i;
		}
		s[s.length-1][0] = x;
		s[s.length-1][1] = y;
		return true;
	}
	
	public getX()->int
	{
		return s[s.length-1][0];
	}
	
	public getY()->int
	{
		return s[s.length-1][1];
	}
	
	s->int[][] = new int[10][2];
}